import jdk.internal.dynalink.linker.LinkerServices;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Admin
 * Date: 2022-04-29
 * Time: 15:55
 */
public class Main {
    public static String[] Suit= {"♠", "♥", "♣", "♦"};
    public static List<Card> buyCard() {
        List<Card> list = new ArrayList<>();
        for (int i = 0; i < 4; i++) {
            for (int j = 1; j < 13; j++) {
                String suit = Suit[i];
                Card card = new Card(suit,j);
                list.add(card);
            }
        }
        return list;
    }

    public static void shuffle(List<Card> cardList) {
        for (int i = cardList.size() - 1; i > 0; i--) {
            Random random = new Random();
            int index = random.nextInt(i);
            Swap(cardList,i,index);
        }
    }

    public static void Swap(List<Card> cardList, int i,int j) {
        Card card = cardList.get(j);
        cardList.set(j,cardList.get(i));
        cardList.set(i,card);
    }
    public static void main(String[] args) {
        List<Card> listCard = buyCard();
        System.out.println(listCard);

        shuffle(listCard);
        System.out.println(listCard);

        List<List<Card>> listList = new ArrayList<>();
        listList.add(new ArrayList<>());
        listList.add(new ArrayList<>());
        listList.add(new ArrayList<>());

        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 5; j++) {
                Card card = listCard.remove(0);
                listList.get(i).add(card);
            }
        }
        System.out.println("第一个玩家：" + listList.get(0));
        System.out.println("第二个玩家：" + listList.get(1));
        System.out.println("第三个玩家：" + listList.get(2));
        System.out.println("剩余的牌：" + listCard);
    }
}